#include "GSphere.h"
#include "GRay3.h"

#include <math.h>

namespace GMath
{

	GSphere::GSphere()
	{
		Center = GVector3::Zero;
		Radius = 0.0f;
	}

	GSphere::GSphere(const GVector3& Center, float Radius)
	{
		Create(Center, Radius);
	}

	GSphere::~GSphere()
	{
	}

	void GSphere::Create(const GVector3& Center, float Radius)
	{
		this->Center = Center;
		this->Radius = Radius;
	}

	float GSphere::GetArea() const
	{
		return 4.0f * G_PI * Radius * Radius;
	}

	float GSphere::GetVolume() const
	{
		return (4.0f / 3.0f) * G_PI * Radius * Radius;
	}

	void GSphere::GetNormal(GVector3& OutNormal, const GVector3& SurfacePoint) const
	{
		OutNormal = SurfacePoint - Center;
		OutNormal.Normalize();
	}

}